package model;

import java.util.Hashtable;

public class daftar {

    private String nama, jk, tempat, asal, alamat, tglLahir;
    private float bi, bing, mtk, ipa, jml;
    private String kode;
    private Hashtable errors;

    public boolean validate() {
        boolean bool = true;
        if (nama.equals("")) {
            errors.put("Nama Lengkap", "Masukkan nama lengkap anda");
            nama = "";
            bool = false;
        }
        
        if (tempat.equals("")) {
            errors.put("Tempat Lahir", "Masukkan tempat lahir anda");
            nama = "";
            bool = false;
        }
        
        if (asal.equals("")) {
            errors.put("Asal SMP", "Masukkan asal SMP anda");
            nama = "";
            bool = false;
        }
        
        if (alamat.equals("")) {
            errors.put("Alamat", "Masukkan alamat anda");
            nama = "";
            bool = false;
        }
        
        if (jk.equals("")) {
            errors.put("Jenis Kelamin", "Pilih jenis kelamin anda");
            nama = "";
            bool = false;
        }
        
        return bool;
    }
    
    public daftar(){
        errors = new Hashtable();
    }

    public void setErrors(String key, String msg) {
        errors.put(key, msg);
    }

    public String getErrorMsg(String s) {
        String errorMsg = (String) errors.get(s.trim());
        return (errorMsg == null) ? "" : errorMsg;
    }

    public void setNama(String nama) {
        this.nama = nama;
    }

    public void setJk(String jk) {
        this.jk = jk;
    }

    public void setTempat(String tempat) {
        this.tempat = tempat;
    }

    public void setAsal(String asal) {
        this.asal = asal;
    }

    public void setAlamat(String alamat) {
        this.alamat = alamat;
    }

    public String getNama() {
        return nama;
    }

    public String getJk() {
        return jk;
    }

    public String getTempat() {
        return tempat;
    }

    public String getAsal() {
        return asal;
    }

    public String getAlamat() {
        return alamat;
    }

    public void setKode(String kode) {
        this.kode = kode;
    }

    public String getKode() {
        return kode;
    }

    public void setBi(float bi) {
        this.bi = bi;
    }

    public void setBing(float bing) {
        this.bing = bing;
    }

    public void setMtk(float mtk) {
        this.mtk = mtk;
    }

    public void setIpa(float ipa) {
        this.ipa = ipa;
    }

    public float getBi() {
        return bi;
    }

    public float getBing() {
        return bing;
    }

    public float getMtk() {
        return mtk;
    }

    public float getIpa() {
        return ipa;
    }

    public void setJml(float jml) {
        this.jml = jml;
    }

    public float getJml() {
        return jml = getBi() + getBing() + getMtk() + getIpa();
    }

    public void setTglLahir(String tglLahir) {
        this.tglLahir = tglLahir;
    }

    public String getTglLahir() {
        return tglLahir;
    }
}
